package com.ruoyi.system.enums;

import lombok.Getter;

/**
 * 消息推送操作类型枚举
 * 用于消息推送操作日志中的action字段
 */
@Getter
public enum MsgActionEnum {
    
    CREATE(1, "创建"),
    DRAFT(2, "草稿"),
    PUSH(3, "推送"),
    SCHEDULE(4, "定时"),
    READ(5, "已读"),
    SIGN(6, "签字"),
    EXPIRE(7, "过期"),
    RETRY(8, "重推"),
    CANCEL(9, "取消"),
    CONFIRM(10, "确认");

    private final Integer code;
    private final String description;

    MsgActionEnum(Integer code, String description) {
        this.code = code;
        this.description = description;
    }

    /**
     * 根据代码获取枚举
     */
    public static MsgActionEnum getByCode(Integer code) {
        for (MsgActionEnum action : values()) {
            if (action.getCode().equals(code)) {
                return action;
            }
        }
        return null;
    }

    /**
     * 根据描述获取枚举
     */
    public static MsgActionEnum getByDescription(String description) {
        for (MsgActionEnum action : values()) {
            if (action.getDescription().equals(description)) {
                return action;
            }
        }
        return null;
    }

    /**
     * 根据代码获取描述
     */
    public static String getDescription(Integer code) {
        MsgActionEnum action = getByCode(code);
        return action != null ? action.getDescription() : null;
    }

    /**
     * 根据描述获取代码
     */
    public static Integer getCode(String description) {
        MsgActionEnum action = getByDescription(description);
        return action != null ? action.getCode() : null;
    }
}
